<?php 
require './jssdk.php';
$con = new JSSDK('appId','appScreat');
$signPackage = $con->GetSignPackage();
if($_POST){
    foreach($_POST['wxid'] as $value){
        $ok = $con -> getmedia($value,'lidaye');
    }
    echo '<script>alert("上传成功");</script>';
}
?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/news.css">
<title>体验店申请</title>
<!-- Bootstrap -->
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script type='text/javascript' src='js/mobileBUGFix.mini.js'></script>
<script src='http://res.wx.qq.com/open/js/jweixin-1.2.0.js'></script>
</head>
<body>
    <img style="display:none;" class="preview-img" src="">
    <div id="apply_store" class="apply_store">
        <div class="apply_wap">
            <div class="page-top">
                <img src="images/store-cateimg.jpg" width="100%">
            </div>
            <div class="validform-con">
                <div class="store-form">
                    <h3 class="font-color store-form-title mb10">体验店申请表</h3>
                    <div class="store-form-aciton">
                        <form id="upload-form" action="" method="post">
                            <div class="input-desprate clear mb10 inline-block">
                                <div style="width:100%;padding: 5px 0;"><span></span><label style="color: #000;">门店和证件照片上传：</label><span style="font-size: 1.2rem;color: #A9A9A9;">请先上传完整清晰的门头正面照片，再上传店面内景照片、营业执照照片，以便于服务。</span></div>
                                <input type="button" id="uploadphoto" class="upload-btn" name="uploadfile" value="门店照片上传"/>
                                <div class="upload-imglist"><ul></ul></div>
                                <div class="clear"></div>
                            </div>
                            <div style="width:100%;text-align:center;">
                            <input style="pavdding: 5px 0;background-color: #eaa530;color: #fff;font-size: 1.4rem;width: 40%;" id="sub" type="submit" value="提交">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '<?php echo $signPackage['appId'];?>', // 必填，公众号的唯一标识
            timestamp: '<?php echo $signPackage['timestamp'];?>', // 必填，生成签名的时间戳
            nonceStr: '<?php echo $signPackage['nonceStr'];?>', // 必填，生成签名的随机串
            signature: '<?php echo $signPackage['signature'];?>',// 必填，签名，见附录1
            jsApiList: ['chooseImage','uploadImage','downloadImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        $(function(){
            $('#uploadphoto').click(function(){
                wx.chooseImage({
                    count: 1, // 默认9
                    sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                    success: function (res) {
                        var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                        var attstr= '<li style="position: relative;"><a href="javascript:;"><img class="upload-img" src="'+localIds+'" width="100%"><img class="del-img" style="position: absolute;left:7%;top:7%;" src="images/delete_icon.png" alt="del" width="14%"></a><input class="wxid" type="hidden" name="wxid[]" value="'+localIds+'"/></li>'; 
                        $(".upload-imglist ul").append(attstr);
                        wx.uploadImage({
                            localId:$('.wxid').last().val(),
                            isShowProgressTips: 1, // 默认为1，显示进度提示
                            success: function (res2) {
                                $('.wxid').last().val(res2.serverId);
                            }
                        });
                        $('.upload-imglist').show();
                    }
                });
              });
            $('body').on('click','.del-img',function(){
                $(this).parent('a').parent('li').remove();
//                alert($(this).parent('a').next('input').val());
            })
          });
    </script>
<!--
    var attstr= '<li><a href="javascript:;"><img src="'+serverId+'"></a><input type="hidden" name="img[]" value="'+serverId+'"/></li>'; 
    $(".upload-imglist ul").append(attstr);
-->
</body>
</html>
  